import React, { Component } from 'react'
import { connect } from 'react-redux';
import { actions } from './_index'

class View extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        const { index, val,onRemoveFn } = this.props
        return (
            <li key={index}>
                {val.id} - {val.type} -{val.text}
                <span onClick={() => { onRemoveFn() }}>删除</span>
            </li>
        )
    }
}
const mapDispatchToProps = (dispatch, ownProps) => {
    console.log(ownProps)
    // ownProps获取父组件的参
    const { val,id } = ownProps;
    // let id = 0;
    return {
        onRemoveFn: () => dispatch(actions.del('删除',val.id))
    }
}

export default connect(null,mapDispatchToProps)(View)
// export default View